<?php
/*
 * @Author: your name
 * @Date: 2020-10-26 11:25:19
 * @LastEditTime: 2020-10-26 13:51:31
 * @LastEditors: Please set LastEditors
 * @Description: ips主机
 * @FilePath: /special/application/adminapiv3/service/module_manage/hgshield/HgshieldHostService.php
 */
namespace app\adminapiv3\service\module_manage\hgshield;

use app\adminapiv3\service\CommonHostService;
use app\common\service\IpsConfig;

class HgshieldHostService extends CommonHostService
{
    public $module_name = 'hgshield';
    /**
     * @name: 配置
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-10-26 13:19:52
     */
    public function config($hostId_a)
    {
        $IpsConfig = new IpsConfig();

        $config = $IpsConfig->selectByHostId($hostId_a, 'type,black,firewall,protect_ip,device_ip,status,host_id');

        foreach ($config as $v)
        {
            $return[$v['host_id']] = $v;
        }

        return $return;
    }

    /**
     * @name: 处理列表
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-10-26 13:20:57
     */
    public function processList ($data)
    {
        if (empty($data))
        {
            return [];
        }
        $return = [];
        foreach ($data as  $k => $v)
        {
            $hostId_a[] = $v['id'];
        }

        $moduleData = $this->moduleData($this->module_name, $hostId_a);
        foreach ($data as $k => $v)
        {
            $return[$k] = $this->processOne([], $v);
            !isset($moduleData[$v['id']]) ? : $return[$k][$this->module_name] = $moduleData[$v['id']];
        }

        return $return;
    }
}